package com.injurydetection.www.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.injurydetection.www.bean.InvokPortBean;
import com.injurydetection.www.util.datautil.SerialPortService1;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by sunguiyong on 2020/9/18
 */
public class PowerScreenReceiver extends BroadcastReceiver {
    private static final String TAG = "PowerScreenReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
            Log.e(TAG, "receive screen off");
            EventBus.getDefault().post(new InvokPortBean(false));
        } else if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
            Log.e(TAG, "receive screen on");
            EventBus.getDefault().post(new InvokPortBean(true));
        }
    }
}
